import 'package:camera/camera.dart';
import 'package:flutter/foundation.dart';
import 'package:get/get.dart';

class BiometricIdentificationController extends GetxController {

  late CameraController cameraController;

  // 初始化相机
  initCamera() async {
    final cameras = await availableCameras();
    final firstCamera = cameras.last;
    cameraController = CameraController(firstCamera, ResolutionPreset.veryHigh);
    cameraController.initialize().then((_) {
      update();
    });
  }

  // 拍照
  takePicture() async {
    if (cameraController.value.isInitialized) {
      final img = await cameraController.takePicture();
      final Uint8List list = await img.readAsBytes();
    }
  }


  @override
  void onReady() {
    super.onReady();
    initCamera();
  }

  @override
  void onClose() {
    cameraController.dispose();
    super.onClose();
  }


}
